What is bin-version?
The bin-version npm package is designed to retrieve the version of a binary executable in your system. It is useful for developers who need to programmatically check and manage the versions of dependencies and tools that their applications interact with.
What are bin-version's main functionalities?
Get binary version
This feature allows you to fetch the version of a specified binary executable. The code sample demonstrates how to retrieve the version of 'curl' using the bin-version package.
const binVersion = require('bin-version');
(async () => {
try {
const version = await binVersion('curl');
console.log(version);
} catch (error) {
console.error('Error:', error);
}
})();
Other packages similar to bin-version
command-exists
This package checks if a given command exists in the system path. Unlike bin-version, which retrieves the version of the binary, command-exists simply checks for the existence of the binary without providing version information.
find-versions
find-versions is a package that extracts semver versions from a string. It can be used in conjunction with other tools to parse version numbers from command output, offering a more flexible approach compared to bin-version which directly fetches the version from the binary.
bin-version
Get the version of a binary in semver format
Install
$ npm install --save bin-version
Usage
$ curl --version
curl 7.30.0 (x86_64-apple-darwin13.0)
const binVersion = require('bin-version');
binVersion('curl').then(version => {
console.log(version);
});
$ openssl version
OpenSSL 1.0.2d 9 Jul 2015
binVersion('openssl', {args: ['version']}).then(version => {
console.log(version);
});
CLI
See the find-versions CLI.
License
MIT © Sindre Sorhus